#pragma strict

var timeToDeath:float = 5;
private var timeElapsed:float = 0;

private var restorePosition:Transform;

function Start () {
	restorePosition = GameObject.Find("RestorePosition").transform;
}

function Update () {

	timeElapsed += Time.deltaTime;
	Debug.Log("timeElapsed:" + timeElapsed + " timeToDeath:" + timeToDeath);
	if (timeElapsed > timeToDeath)
	{
		Destroy(gameObject);
		Debug.Log("Destruyendo Fireball");
	}
}

function OnTriggerEnter (other : Collider)
{
	if (other.tag == "Player")
	{
		other.transform.position = restorePosition.position;
		Destroy(gameObject);
	}
		
}